package com.nbsaas.boot.product.rest.convert;

import com.nbsaas.boot.product.data.entity.ProductImage;
import com.nbsaas.boot.product.api.domain.simple.ProductImageSimple;

import com.nbsaas.boot.rest.api.Converter;

/**
* 商品图片-列表对象转换器
*/

public class ProductImageSimpleConvert implements Converter<ProductImageSimple, ProductImage> {




@Override
public ProductImageSimple convert(ProductImage source) {
    ProductImageSimple result = new ProductImageSimple();

                result.setPath(source.getPath());
                result.setNote(source.getNote());

               try {
                   if(source.getProduct()!=null){
                       result.setProduct(source.getProduct().getId());
                   }
                } catch (Exception ignored) { }

                result.setSortNum(source.getSortNum());
                result.setId(source.getId());
                result.setAddDate(source.getAddDate());

                try {
                    if(source.getProduct()!=null){
                        result.setProductName(source.getProduct().getName());
                    }
                } catch (Exception ignored) { }

                result.setLastDate(source.getLastDate());


    return result;
}

}